package 第3节函数;

public class FunctionDemo {
    public static void main(String[] args) {
        double r1 = pow(2,3);
        System.out.println(r1);
        System.out.println(pow(3,3));
        printTriangle(4);
    }
    public static void printTriangle(int n) {
        if (n == 5) {
            return;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
        return;
    }
    public static double pow(double n, int x) {
        double result = 1.0;
        for (int i = 0; i < x; i++) {
            result = result * n;
        }
        return result;
    }
}
